mdbt42q 2.2.0
Loading...
Searching...
No Matches
main.c File Reference

MDBT42Q Click Example. More...

#include "board.h"
#include "log.h"
#include "mdbt42q.h"

Macros

#define MESSAGE_CONTENT   "MDBT42Q Click board - demo example."
#define DEVICE_NAME   "MDBT42Q Click"
#define APP_BUFFER_SIZE   600
#define PROCESS_BUFFER_SIZE   200
#define READ_RESPONSE_TIMEOUT_MS   60000
#define BT_TERMINAL_TIMEOUT_MS   60000
#define BT_TERMINAL_MESSAGE_FREQ_MS   5000
#define TERMINATION_CMD   "END"
#define TERMINATION_RESPONSE   "Acknowledged, the connection will be terminated in a few seconds."
#define TERMINATION_TIMEOUT   "Timeout, closing the connection in a few seconds."
#define NEW_LINE_STRING   "\r\n"

Enumerations

enum  mdbt42q_app_state_t { MDBT42Q_POWER_UP = 1 , MDBT42Q_CONFIG_EXAMPLE , MDBT42Q_EXAMPLE }
 Example states. More...

Functions

void application_init (void)
void application_task (void)
int main (void)

Detailed Description

MDBT42Q Click Example.

Description

This example demonstrates the use of MDBT42Q Click board by processing data from a connected BT device.

The demo application is composed of two sections :

Application Init

Initializes the driver and logger.

Application Task

Application task is split in few stages:

  • MDBT42Q_POWER_UP: Powers up the device, performs a factory reset and reads system information.
  • MDBT42Q_CONFIG_EXAMPLE: Sets the BT device name.
  • MDBT42Q_EXAMPLE: Performs a BT terminal example by processing all data from a connected BT device and sending back an adequate response messages.

Additional Function

  • static void mdbt42q_clear_app_buf ( void )
  • static void mdbt42q_log_app_buf ( void )
  • static err_t mdbt42q_process ( mdbt42q_t *ctx )
  • static err_t mdbt42q_read_response ( mdbt42q_t *ctx )
  • static err_t mdbt42q_power_up ( mdbt42q_t *ctx )
  • static err_t mdbt42q_config_example ( mdbt42q_t *ctx )
  • static err_t mdbt42q_example ( mdbt42q_t *ctx )
Note
We have used the Serial Bluetooth Terminal smartphone application for the test.
Author
Stefan Filipovic

Macro Definition Documentation

◆ APP_BUFFER_SIZE

#define APP_BUFFER_SIZE   600

◆ BT_TERMINAL_MESSAGE_FREQ_MS

#define BT_TERMINAL_MESSAGE_FREQ_MS   5000

◆ BT_TERMINAL_TIMEOUT_MS

#define BT_TERMINAL_TIMEOUT_MS   60000

◆ DEVICE_NAME

#define DEVICE_NAME   "MDBT42Q Click"

◆ MESSAGE_CONTENT

#define MESSAGE_CONTENT   "MDBT42Q Click board - demo example."

◆ NEW_LINE_STRING

#define NEW_LINE_STRING   "\r\n"

◆ PROCESS_BUFFER_SIZE

#define PROCESS_BUFFER_SIZE   200

◆ READ_RESPONSE_TIMEOUT_MS

#define READ_RESPONSE_TIMEOUT_MS   60000

◆ TERMINATION_CMD

#define TERMINATION_CMD   "END"

◆ TERMINATION_RESPONSE

#define TERMINATION_RESPONSE   "Acknowledged, the connection will be terminated in a few seconds."

◆ TERMINATION_TIMEOUT

#define TERMINATION_TIMEOUT   "Timeout, closing the connection in a few seconds."

Enumeration Type Documentation

◆ mdbt42q_app_state_t

Example states.

Predefined enum values for application example state.

Enumerator
MDBT42Q_POWER_UP 
MDBT42Q_CONFIG_EXAMPLE 
MDBT42Q_EXAMPLE 

Function Documentation

◆ application_init()

void application_init ( void )

< Logger config object.

< Click config object.

Logger initialization. Default baud rate: 115200 Default log level: LOG_LEVEL_DEBUG

Note
If USB_UART_RX and USB_UART_TX are defined as HAL_PIN_NC, you will need to define them manually for log to work. See LOG_MAP_USB_UART macro definition for detailed explanation.

◆ application_task()

void application_task ( void )

◆ main()

int main ( void )